{{- $params := site.Params }}
{{- $separator := default "|" $params.titleSeparator }}
{{- $title := "" }}
{{- if and .Title (ne (trim (lower .Site.Title) "") (trim (lower .Title) "")) }}
    {{- if eq .Kind "taxonomy" }}
        {{- $title = default .Title ( T (lower .Title) ) }}
    {{- else }}
        {{- $title = .Title }}
    {{- end }}
{{- end }}
<title>{{ with $title }}{{ . }} {{ $separator }} {{ end }}{{ .Site.Title }}</title>
<meta charset="utf-8">
{{ if .Params.noindex }}
    <meta name="robots" content="noindex" />
{{ end }}
{{- with $params.ga_verify }}
    <meta name="google-site-verification" content="{{ . }}">
{{- end }}
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
{{- if (ne hugo.Environment "development") }}
    {{- partialCached "head/component/analytics" . }}
{{- end }}
{{- partial "head/component/opengraph" . }}
{{- partialCached "head/component/favicon" . }}
<link rel="canonical" href="{{ .Permalink }}">
{{ range .AlternativeOutputFormats -}}
    {{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
{{ end -}}
<!-- waline 评论框样式 -->
{{- $showComments := true }}
{{- if eq $params.comments false }}
    {{- $showComments = false }}
{{- else if eq .Params.comments false }}
    {{- $showComments = false }}
{{- end }}
{{- if ne $showComments false }}
    <link rel="stylesheet" href="https://unpkg.com/@waline/client@v3/dist/waline.css" />
{{- end }}

<!-- preload assets declaration -->
<!-- preload main css file -->
{{ $styles := partialCached "func/getStylesBundle" . }}
<link rel="preload" href="{{ $styles.Permalink }}" integrity = "{{ $styles.Data.Integrity }}" as="style" crossorigin="anonymous">

<!-- preload main javascript file -->
{{ $bundle := partialCached "func/getJavascriptBundle" . }}
<link rel="preload" href="{{ $bundle.Permalink }}" as="script" integrity=
"{{ $bundle.Data.Integrity }}" crossorigin="anonymous">

<!-- link main css file -->
<link rel="stylesheet" type="text/css" href="{{ $styles.Permalink }}" integrity="{{ $styles.Data.Integrity }}" crossorigin="anonymous">
<!-- load all custom css files -->
{{- with $params.customCSS }}
    {{- range . -}}
        <link rel="stylesheet" href="{{ relURL . }}">
    {{- end }}
{{- end }}

<!-- 需要配置中增加math参数，并开启mathjax。 可以全站设定math=true，也可以在单个页面中的头部设置-->
{{ if or .Params.math .Site.Params.math }}
    <script>
        MathJax = {
            tex: {
                inlineMath: [["$", "$"], ["$$", "$$"], ["\\$", "\\$"], ["\\(", "\\)"]],
                displayMath: [["\\$$", "\\$$"], ["\\[", "\\]"]],
                processEscapes: true,
                processEnvironments: true
            },
            options: {
                skipHtmlTags: ['script', 'noscript', 'style', 'textarea', 'pre']
            }
        };
    </script>
    <script id="MathJax-script" async src="/mathjax/es5/tex-mml-chtml.js"></script>
{{ end }}